package com.yhm.myfootbollshow.demos.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yhm.myfootbollshow.demos.base.ResVo;
import com.yhm.myfootbollshow.demos.entity.dto.LoginUser;
import com.yhm.myfootbollshow.demos.entity.dto.UserDto;
import com.yhm.myfootbollshow.demos.entity.dto.banUser;
import com.yhm.myfootbollshow.demos.entity.po.Merchant;
import com.yhm.myfootbollshow.demos.entity.po.User;
import com.yhm.myfootbollshow.demos.entity.po.UserAddress;
import com.yhm.myfootbollshow.demos.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @author: yhm
 * @time: 2025/3/31 17:52
 */
@RestController
@RequestMapping("/yhm/user")
public class UserController{
    @Resource
    private UserService userService;

    @PostMapping("/login")
    public ResVo login(LoginUser loginUser){
        return userService.Login(loginUser);
    }

    @PostMapping("/register")
    public ResVo<Boolean> register(User user){
        return ResVo.ok(userService.register(user));
    }

    @PostMapping("/list")
    public ResVo<IPage<User>> list(UserDto user){
        return ResVo.ok(userService.list(user));
    }

    @PostMapping("/banUser")
    public ResVo<Boolean> banUser(banUser user){
        return ResVo.ok(userService.banUser(user));
    }

    @PostMapping("/updateUser")
    public ResVo<Boolean> upPwd(Long userId,String username,String password){
        return ResVo.ok(userService.updateUser(userId,username,password));
    }

    @GetMapping("/listAddress")
    public ResVo<List<UserAddress>> listAdd(Long userId){
        return ResVo.ok(userService.listAdd(userId));
    }
    @PostMapping("/addAddress")
    public ResVo<Boolean> addAddress(UserAddress userAddress){
        return ResVo.ok(userService.addAddress(userAddress));
    }
}
